<?
global $config;

$e = $params;
$link = $e["link"];

$n = 0; while ($n<10 && ob_get_length()) { ob_end_clean(); $n++; }

$types = array(
	"gif"=>"image/gif",
	"png"=>"image/png",
	"jpg"=>"image/jpeg",
	);

foreach ($types as $k=>$v) {
	if (preg_match("/\.$k\$/i",$link)) {
		header("Content-type: $v");
		}
	}
	
$fname = "{$config["wiki.datadir"]}/{$e["fname"]}";

header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($fname));

readfile($fname);
die;
?>